package com.yewen.http.service;

import com.yewen.http.entity.EducationCounselor;
import com.yewen.http.repository.EducationCounselorRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Classname EducationCounselorService
 * @Description TODO
 * @Date 2022/3/30 22:43
 * @Created by TaoVh
 */
@Service
public class EducationCounselorService {
    @Autowired
    EducationCounselorRepository repository;
    public boolean register(EducationCounselor educationCounselor){
        return repository.save(educationCounselor);
    }

    public List<EducationCounselor> getAllEduCounselors(){
        return repository.findAll();
    }
    public boolean checkTelExisted(String tel){
        return repository.findByTel(tel).size()!=0;
    }
    public boolean checkEmailExisted(String email){
        return repository.findByEmail(email).size()!=0;
    }
    public boolean inline(String id){
        return repository.updateState(id,true);
    }
    public boolean offline(String id){
        return repository.updateState(id,false);
    }
    public List<EducationCounselor> getEduCounselorsByMajor(String major){
        return repository.findByMajor(major);
    }
}
